/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.marlboroug.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;


@Entity
@Table(name = "Articles")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Articles.findAll", query = "SELECT a FROM Articles a"),
    @NamedQuery(name = "Articles.findByIDarticles", query = "SELECT a FROM Articles a WHERE a.iDarticles = :iDarticles"),
    @NamedQuery(name = "Articles.findByName", query = "SELECT a FROM Articles a WHERE a.name = :name"),
    @NamedQuery(name = "Articles.findByImage", query = "SELECT a FROM Articles a WHERE a.image = :image"),
    @NamedQuery(name = "Articles.findByReleaseDate", query = "SELECT a FROM Articles a WHERE a.releaseDate = :releaseDate"),
    @NamedQuery(name = "Articles.findByRef", query = "SELECT a FROM Articles a WHERE a.ref = :ref"),
    @NamedQuery(name = "Articles.findByPrice", query = "SELECT a FROM Articles a WHERE a.price = :price"),
    @NamedQuery(name = "Articles.findByState", query = "SELECT a FROM Articles a WHERE a.state = :state"),
    @NamedQuery(name = "Articles.findByLimitStock", query = "SELECT a FROM Articles a WHERE a.limitStock = :limitStock"),
    @NamedQuery(name = "Articles.findByQuantityStock", query = "SELECT a FROM Articles a WHERE a.quantityStock = :quantityStock"),
    @NamedQuery(name = "Articles.findBySold", query = "SELECT a FROM Articles a WHERE a.sold = :sold")})
public class Articles implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_articles")
    private Long iDarticles;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "name")
    private String name;
    @Size(max = 200)
    @Column(name = "image")
    private String image;
    @Lob
    @Size(max = 65535)
    @Column(name = "summary")
    private String summary;
    @Column(name = "release_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date releaseDate;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "ref")
    private String ref;
    @Basic(optional = false)
    @NotNull
    @Column(name = "price")
    private float price;
    @Basic(optional = false)
    @NotNull
    @Column(name = "state")
    private int state;
    @Basic(optional = false)
    @NotNull
    @Column(name = "limit_stock")
    private int limitStock;
    @Basic(optional = false)
    @NotNull
    @Column(name = "quantity_stock")
    private int quantityStock;
    @Basic(optional = false)
    @NotNull
    @Column(name = "sold")
    private int sold;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idArticles")
    private Collection<Articlesbyauthors> articlesbyauthorsCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idArticles")
    private Collection<Articlesordered> articlesorderedCollection;
    @JoinColumn(name = "id_categories", referencedColumnName = "ID_categories")
    @ManyToOne(optional = false)
    private Categories idCategories;
    @JoinColumn(name = "id_editors", referencedColumnName = "ID_editors")
    @ManyToOne(optional = false)
    private Editors idEditors;

    public Articles() {
    }

    public Articles(Long iDarticles) {
        this.iDarticles = iDarticles;
    }

    public Articles(Long iDarticles, String name, String ref, float price, int state, int limitStock, int quantityStock, int sold) {
        this.iDarticles = iDarticles;
        this.name = name;
        this.ref = ref;
        this.price = price;
        this.state = state;
        this.limitStock = limitStock;
        this.quantityStock = quantityStock;
        this.sold = sold;
    }

    public Long getIDarticles() {
        return iDarticles;
    }

    public void setIDarticles(Long iDarticles) {
        this.iDarticles = iDarticles;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public String getSummary() {
        return summary;
    }

    public void setSummary(String summary) {
        this.summary = summary;
    }

    public Date getReleaseDate() {
        return releaseDate;
    }

    public void setReleaseDate(Date releaseDate) {
        this.releaseDate = releaseDate;
    }

    public String getRef() {
        return ref;
    }

    public void setRef(String ref) {
        this.ref = ref;
    }

    public float getPrice() {
        return price;
    }

    public void setPrice(float price) {
        this.price = price;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public int getLimitStock() {
        return limitStock;
    }

    public void setLimitStock(int limitStock) {
        this.limitStock = limitStock;
    }

    public int getQuantityStock() {
        return quantityStock;
    }

    public void setQuantityStock(int quantityStock) {
        this.quantityStock = quantityStock;
    }

    public int getSold() {
        return sold;
    }

    public void setSold(int sold) {
        this.sold = sold;
    }

    @XmlTransient
    public Collection<Articlesbyauthors> getArticlesbyauthorsCollection() {
        return articlesbyauthorsCollection;
    }

    public void setArticlesbyauthorsCollection(Collection<Articlesbyauthors> articlesbyauthorsCollection) {
        this.articlesbyauthorsCollection = articlesbyauthorsCollection;
    }

    @XmlTransient
    public Collection<Articlesordered> getArticlesorderedCollection() {
        return articlesorderedCollection;
    }

    public void setArticlesorderedCollection(Collection<Articlesordered> articlesorderedCollection) {
        this.articlesorderedCollection = articlesorderedCollection;
    }

    public Categories getIdCategories() {
        return idCategories;
    }

    public void setIdCategories(Categories idCategories) {
        this.idCategories = idCategories;
    }

    public Editors getIdEditors() {
        return idEditors;
    }

    public void setIdEditors(Editors idEditors) {
        this.idEditors = idEditors;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (iDarticles != null ? iDarticles.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Articles)) {
            return false;
        }
        Articles other = (Articles) object;
        if ((this.iDarticles == null && other.iDarticles != null) || (this.iDarticles != null && !this.iDarticles.equals(other.iDarticles))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.marlboroug.entity.Articles[ iDarticles=" + iDarticles + " ]";
    }
    
}
